/*
 * Copyright 2009 XueSong Guo.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package cn.webwheel.utils;

import cn.webwheel.Action;
import cn.webwheel.ResultInterpreter;
import cn.webwheel.WebContext;

/**
 * 简单结果{@link SimpleResult}的解释器。
 */
public class SimpleResultInterpreter implements ResultInterpreter<SimpleResult> {
    public void init() throws Exception {
    }

    /**
     * 通过简单结果自身的{@link SimpleResult#render()}方法进行渲染。
     * @param result 简单结果
     * @param ctx 应用程序上下文
     * @param action 返回简单结果的动作类
     * @return 是否已经处理了此次http请求，永远返回true
     * @throws Exception 任何异常
     */
    public boolean render(SimpleResult result, WebContext ctx, Action action) throws Exception {
        result.setWebContext(ctx);
        result.render();
        return true;
    }

    public void destroy() {
    }
}
